<!---->
<!-- AAChartView.html-->
<!-- AAChartKit-Swift-->
<!---->
<!-- Created by An An on 17/4/19.-->
<!-- Copyright © 2017年 An An . All rights reserved.-->
<!--*************** ...... SOURCE CODE ...... ***************-->
<!--***...................................................***-->
<!--*** https://github.com/AAChartModel/AAChartKit        ***-->
<!--*** https://github.com/AAChartModel/AAChartKit-Swift  ***-->
<!--***...................................................***-->
<!--*************** ...... SOURCE CODE ...... ***************-->
<!--/*-->
<!---->
<!--* --------------------------------------------------------------------------------->
<!--* 🌕 🌖 🌗 🌘 ❀❀❀ WARM TIPS!!! ❀❀❀ 🌑 🌒 🌓 🌔-->
<!--*-->
<!--* Please contact me on GitHub,if there are any problems encountered in use.-->
<!--* GitHub Issues : https://github.com/AAChartModel/AAChartKit-Swift/issues-->
<!--* --------------------------------------------------------------------------------->
<!--* And if you want to contribute for this project, please contact me as well-->
<!--* GitHub        : https://github.com/AAChartModel-->
<!--* StackOverflow : https://stackoverflow.com/users/7842508/codeforu-->
<!--* JianShu       : https://www.jianshu.com/u/f1e6753d4254-->
<!--* SegmentFault  : https://segmentfault.com/u/huanghunbieguan-->
<!--*-->
<!--* --------------------------------------------------------------------------------->
<!---->
<!--*/-->
<html>
    
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=3.0,user-scalable = no">
        <title>AAChartKit-Swift</title>
        <script src="AAHighchartsLib.js"></script>
        <script src="AAHighchartsMore.js"></script>
        <script src="AAFunnel.js"></script>
        <!-- <script src=" https://img.hcharts.cn/highcharts/themes/dark-unica.js">-->
        <!-- </script>-->
        <!-- 若介意本地js代码体积(250KB左右)过大，可换用加载网络js代码 -->
        <!-- <script src="https://img.hcharts.cn/highcharts/highcharts.js">-->
        <!-- </script>-->
        <!-- <script src="https://img.hcharts.cn/highcharts/highcharts-more.js">-->
        <!-- </script>-->
        <style>*{ -webkit-user-select: none; user-select: none; }</style>
    </head>
    
    <body>
        <div id="container" style="width:100%; height: 100%;"></div>
        <script>

            var aaGlobalChart;

            function loadTheHighChartView(sender, receivedWidth, receivedHeight) {
<!--                                alert(sender);-->
                var aaOptions = JSON.parse(sender);
                var o = document.getElementById('container'); //获得元素
                if (receivedWidth != 0) {
                    o.style.width = receivedWidth; //设置宽度
                }
                if(receivedHeight != 0) {
                    o.style.height = receivedHeight; //设置高度
                }
                if (aaOptions.plotOptions) {
                var animationEasingType = aaOptions.plotOptions.series.animation.easing;
                if (animationEasingType) { //懒调用(只有在 aaChartModel 实例对象设置了 animationType 属性值的时候才会调用设置动画类型的函数,否则不调用)
                    aaOptions.plotOptions.series.animation.easing = configureTheChartAnimationEasingType(animationEasingType);
                }
                }
                aaOptions.credits = {
                    enabled: false
                }; //去掉表格右下角版权信息
                
                //全局配置(可通过全局配置设置主题)https://api.hcharts.cn/highcharts#Highcharts.setOptions
                Highcharts.setOptions({
                                      lang: {
                                          thousandsSep: ","
                                      }
                                      });
                
                aaGlobalChart = Highcharts.chart('container', aaOptions);
            };


            function configureTheChartAnimationEasingType(easingType) {
                switch (easingType) {
                case "easeInQuad":
                    return function(pos) {
                        return Math.pow(pos, 2);
                    };
                case "easeOutQuad":
                    return function(pos) {
                        return - (Math.pow((pos - 1), 2) - 1);
                    };
                case "easeInOutQuad":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 2);
                        return - 0.5 * ((pos -= 2) * pos - 2);
                    };
                case "easeInCubic":
                    return function(pos) {
                        return Math.pow(pos, 3);
                    };
                case "easeOutCubic":
                    return function(pos) {
                        return (Math.pow((pos - 1), 3) + 1);
                    };
                case "easeInOutCubic":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 3);
                        return 0.5 * (Math.pow((pos - 2), 3) + 2);
                    };
                case "easeInQuart":
                    return function(pos) {
                        return Math.pow(pos, 4);
                    };
                case "easeOutQuart":
                    return function(pos) {
                        return - (Math.pow((pos - 1), 4) - 1);
                    };
                case "easeInOutQuart":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 4);
                        return - 0.5 * ((pos -= 2) * Math.pow(pos, 3) - 2);
                    };
                case "easeInQuint":
                    return function(pos) {
                        return Math.pow(pos, 5);
                    };
                case "easeOutQuint":
                    return function(pos) {
                        return (Math.pow((pos - 1), 5) + 1);
                    };
                case "easeInOutQuint":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 5);
                        return 0.5 * (Math.pow((pos - 2), 5) + 2);
                    };
                case "easeInSine":
                    return function(pos) {
                        return - Math.cos(pos * (Math.PI / 2)) + 1;
                    };
                case "easeOutSine":
                    return function(pos) {
                        return Math.sin(pos * (Math.PI / 2));
                    };
                case "easeInOutSine":
                    return function(pos) {
                        return ( - 0.5 * (Math.cos(Math.PI * pos) - 1));
                    };
                case "easeInExpo":
                    return function(pos) {
                        return (pos === 0) ? 0 : Math.pow(2, 10 * (pos - 1));
                    };
                case "easeOutExpo":
                    return function(pos) {
                        return (pos === 1) ? 1 : -Math.pow(2, -10 * pos) + 1;
                    };
                case "easeInOutExpo":
                    return function(pos) {
                        if (pos === 0) return 0;
                        if (pos === 1) return 1;
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(2, 10 * (pos - 1));
                        return 0.5 * ( - Math.pow(2, -10 * --pos) + 2);
                    };
                case "easeInCirc":
                    return function(pos) {
                        return - (Math.sqrt(1 - (pos * pos)) - 1);
                    };
                case "easeOutCirc":
                    return function(pos) {
                        return Math.sqrt(1 - Math.pow((pos - 1), 2));
                    };
                case "easeInOutCirc":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return - 0.5 * (Math.sqrt(1 - pos * pos) - 1);
                        return 0.5 * (Math.sqrt(1 - (pos -= 2) * pos) + 1);
                    };
                case "easeOutBounce":
                    return function(pos) {
                        if ((pos) < (1 / 2.75)) {
                            return (7.5625 * pos * pos);
                        } else if (pos < (2 / 2.75)) {
                            return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
                        } else if (pos < (2.5 / 2.75)) {
                            return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
                        } else {
                            return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
                        }
                    };
                case "easeInBack":
                    return function(pos) {
                        var s = 1.70158;
                        return (pos) * pos * ((s + 1) * pos - s);
                    };
                case "easeOutBack":
                    return function(pos) {
                        var s = 1.70158;
                        return (pos = pos - 1) * pos * ((s + 1) * pos + s) + 1;
                    };
                case "easeInOutBack":
                    return function(pos) {
                        var s = 1.70158;
                        if ((pos /= 0.5) < 1) return 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s));
                        return 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
                    };
                case "elastic":
                    return function(pos) {
                        return - 1 * Math.pow(4, -8 * pos) * Math.sin((pos * 6 - 1) * (2 * Math.PI) / 2) + 1;
                    };
                case "swingFromTo":
                    return function(pos) {
                        var s = 1.70158;
                        return ((pos /= 0.5) < 1) ? 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s)) : 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2);
                    };
                case "swingFrom":
                    return function(pos) {
                        var s = 1.70158;
                        return pos * pos * ((s + 1) * pos - s);
                    };
                case "swingTo":
                    return function(pos) {
                        var s = 1.70158;
                        return (pos -= 1) * pos * ((s + 1) * pos + s) + 1;
                    };
                case "bounce":
                    return function(pos) {
                        if (pos < (1 / 2.75)) {
                            return (7.5625 * pos * pos);
                        } else if (pos < (2 / 2.75)) {
                            return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
                        } else if (pos < (2.5 / 2.75)) {
                            return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
                        } else {
                            return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
                        }
                    };
                case "bouncePast":
                    return function(pos) {
                        if (pos < (1 / 2.75)) {
                            return (7.5625 * pos * pos);
                        } else if (pos < (2 / 2.75)) {
                            return 2 - (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75);
                        } else if (pos < (2.5 / 2.75)) {
                            return 2 - (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375);
                        } else {
                            return 2 - (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375);
                        }
                    };
                case "easeFromTo":
                    return function(pos) {
                        if ((pos /= 0.5) < 1) return 0.5 * Math.pow(pos, 4);
                        return - 0.5 * ((pos -= 2) * Math.pow(pos, 3) - 2);
                    };
                case "easeFrom":
                    return function(pos) {
                        return Math.pow(pos, 4);
                    };
                case "easeTo":
                    return function(pos) {
                        return Math.pow(pos, 0.25);
                    }
                }
            }

            function onlyRefreshTheChartDataWithSeries(receivedSeries) {
                var receivedSeriesElementArr = JSON.parse(receivedSeries);

                for (var i = 0; i < receivedSeriesElementArr.length; i++) {
                    var receivedSeriesData = receivedSeriesElementArr[i].data;
                    // 获取series
                    var chartSeries = aaGlobalChart.series[i];
                    // 执行只刷新数据的函数
                    chartSeries.setData(receivedSeriesData);
                }
            }

            //pragma mark -- setter method 适应内容https://code.hcharts.cn/highcharts/4YM0a8
            function setTheChartViewContentWidth(receivedWidth) {
                var container = document.getElementById('container'); //获得元素
                container.style.width = receivedWidth; //设置宽度
                aaGlobalChart.reflow();
            }

            function setTheChartViewContentHeight(receivedHeight) {
                var container = document.getElementById('container'); //获得元素
                container.style.height = receivedHeight; //设置高度
                aaGlobalChart.reflow();
            }
        

            function setChartSeriesHidden(hidden) {
                for (var i = 0; i < aaGlobalChart.series.length; i++) {
                    var series = aaGlobalChart.series[i];
                    if (hidden == true) {
                        series.hide()
                    } else {
                        series.show()
                    }
                }
            }

            function showTheSeriesElementContentWithIndex(elementIndex) {
                var series = aaGlobalChart.series[elementIndex];
                series.show()
            }
            
            function hideTheSeriesElementContentWithIndex(elementIndex) {
                var series = aaGlobalChart.series[elementIndex];
                series.hide()
            }
        
            function evaluateTheJavaScriptStringFunction(jsStringFunction) {
<!--            alert(jsStringFunction);-->
                eval(jsStringFunction);
            }
        
            </script>
    </body>

</html>
